package main

import (
	"encoding/json"
	"fmt"
)

// JSON 转结构体

type P1 struct {
	Name string `xml:"name,attr"`
	Age  int    `xml:"age,attr"`
}

func main() {

	var str = `{"Name":"ddd","Age":21}`

	var p P1

	err := json.Unmarshal([]byte(str), &p)

	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("%#v\n", p)
}
